<template>
	<view>
		<z-paging ref="paging" v-model="infoList" @query="queryList" class="pageView">
			<view class="itemView" v-for="(item,index) in infoList">
				<image src="../../../static/file.png" style="width: 52rpx;height: 60rpx;margin-top: 6rpx;"></image>
				<view class="title">
					<text>{{item.Title}}</text>
					<text class="time">{{item.CreateTime}}</text>
					<view style=" display: flex;flex-direction: row;">
						<view style="flex: 1;"></view>
						<view class="dowload" @click="DownloadFile(item)">
							<image src="../../../static/dowload.png"
								style="width: 22rpx;height: 27rpx;margin-right: 15rpx;"></image>
							<text>下载</text>
						</view>
					</view>
				</view>
			</view>
		</z-paging>
		
		<suspended @userData="childData"></suspended>
	</view>
</template>

<script>
	import {
		GetFileList,
		DownloadFile,
		//requestFile
	} from "../../../common/api.js"
	export default {
		data() {
			return {
				infoList: [],
				baseUrl: getApp().globalData.requesturl,
			}
		},
		methods: {
			async queryList(pageNo, pageSize) {
				var data = {}
				let res = await GetFileList(data)
				this.$refs.paging.complete(res.response);
			},

			async DownloadFile(item) {
				var data = {
					FilePath: item.FilePath,
					fileName: item.fileName
				}
				//let res = await requestFile(data)
				this.playpapers(this.baseUrl + '/api/JieShuiZaiTi/DownloadFile' +
					'?FilePath=' + data.FilePath + '&fileName=' + data.fileName)
				// if(res != null) {
				// 	let res = await DownloadFile(data)
				// }
			},

			playpapers(url) {

				let dload = document.createElement("a");

				dload.download = ''; // 设置下载的文件名，默认是'下载'

				dload.href = url;

				document.body.appendChild(dload);

				dload.click();

				dload.remove(); // 下载之后把创建的元素删除

				// uni.showToast({

				// 	title: "正在下载",

				// 	icon: "success"

				// });

			},

			childData(param) {
				this.$refs.paging.reload();
			}
		}
	}
</script>

<style>
	page {
		width: 100%;
		height: 100%;

		background-color: #F4F4F4;
	}

	.pageView {
		padding: 0 24rpx 0 24rpx;
	}

	.itemView {
		height: auto;
		background: #FFFFFF;
		border-radius: 16rpx;
		display: flex;
		flex-direction: row;
		padding: 24rpx;
		margin-top: 24rpx;
	}

	.title {
		width: 100%;
		font-size: 34rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #333333;
		line-height: 48rpx;
		margin-left: 32rpx;
		display: flex;
		flex-direction: column;
	}

	.time {
		font-size: 24rpx;
		color: #999999;
		line-height: 33rpx;
		margin-top: 16rpx;
	}

	.dowload {
		width: 135rpx;
		height: 60rpx;
		background: #E7F1FF;
		border-radius: 30rpx;
		margin-top: 16rpx;
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;
		font-size: 24rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #1677FF;
		line-height: 33rpx;
	}
</style>
